const util = require('../utils/util.js');
const api = require('../config/api.js');

function add(data, callback) {
    util.request(api.cartAdd, data, 'POST', (res) => {
        typeof callback == "function" && callback(res)
    })
}

function sub(data, callback) {
    util.request(api.cartSub, data, 'POST', (res) => {
        typeof callback == "function" && callback(res)
    })
}

function total(data, callback) {
    util.request(api.cartTotal, data, 'GET', (res) => {
        typeof callback == "function" && callback(res)
    })
}

function list(data, callback) {
    util.request(api.cartList, data, 'GET', (res) => {
        typeof callback == "function" && callback(res)
    })
}

function del(data, callback) {
    util.request(api.cartDel, data, 'POST', (res) => {
        typeof callback == "function" && callback(res)
    })
}

module.exports = {
    add,
    total,
    list,
    del,
    sub,
};
